<script>
import { isVip, showModal } from "@/utils"
import pay from "@/utils/pay"

export default {
  name: "index",
  methods: {
    async checkIsVip(redirectUrl) {
      //检查是否开启了ios支付
      if (!(await pay.checkIosPay())) {
        await showModal({
          title: "提示",
          content: "由于相关规范，ios功能暂不可用",
          showCancel: false,
        })
        return
      }
      //弹出开通vip弹窗
      if (!(await isVip())) {
        showModal({
          title: "提示",
          content: "普通用户暂不能体验该功能，点击解锁获得优质体验吧~",
          cancelText: "取消",
          confirmText: "前往解锁",
        }).then((boolean) => {
          if (boolean) {
            if (redirectUrl) {
              uni.navigateTo({
                url: "/pages/mine/vipList?redirectUrl=" + encodeURIComponent(redirectUrl),
              })
            } else {
              uni.navigateTo({
                url: "/pages/mine/vipList",
              })
            }
          }
        })
        return false
      } else {
        return true
      }
    },
  },
}
</script>

<template>
  <view></view>
</template>

<style scoped lang="scss"></style>
